package com.Studen.controller;

import com.Studen.Dao.LoginDaoMpl;
import com.Studen.bean.User;
import com.Studen.servlet.DDLServlet;
import com.Studen.servlet.DDLServletMpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/del")
public class detectController extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 获取前台传来的要删除人的id 和管理员的id
         * 将管理员的id封装在User对象里给servlet
         *
         * **/
        int id= Integer.parseInt(request.getParameter("v"));

        String adm=(request.getParameter("id"));
        //把前台传过来要删除人的id用来与servlet层相关操作
        DDLServlet d = new DDLServletMpl();
        d.Detect(id);
        //把前台传过来老师的id用来获取老师的相关信息
        List<User> admU = d.getamd(adm);
        //获取数据老师获得相关操作的数据
        List<User> arr = new LoginDaoMpl().show();

        request.setAttribute("user",arr);
        request.setAttribute("u",admU);
        request.getRequestDispatcher("main.jsp").forward(request,response);
    }

}
